
package com.yulebaby.callsenter.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yulebaby.callsenter.R;
import com.yulebaby.callsenter.bean.PreSaleRemarkBean;
import com.yulebaby.callsenter.global.Constant;
import com.yulebaby.callsenter.utils.DateUtil;

import java.util.List;


/**
 * Author: Zhangbo
 * Time: 2016/12/09
 * 售前跟踪记录 Adapter  搞麻烦了 T_T
 * <p>
 */

public class PreSaleRemarkAdapter extends BaseQuickAdapter<PreSaleRemarkBean, BaseViewHolder> {

    public PreSaleRemarkAdapter(List<PreSaleRemarkBean> list) {
        super(R.layout.item_recycle_presaleremark, list);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, PreSaleRemarkBean preSaleRemarkBean) {
        TextView tv_trackNone = baseViewHolder.getView(R.id.tv_trackprogress_none);
        TextView tv_trackExist = baseViewHolder.getView(R.id.tv_trackprogress_exist);
        View rl_trackProgress = baseViewHolder.getView(R.id.rl_trackprogress);
        baseViewHolder.setText(R.id.tv_time, DateUtil.formatDateTimeDetail(preSaleRemarkBean.getVisit_time())) //跟踪时间
                .setText(R.id.tv_trackmode, checkNull(preSaleRemarkBean.getVisit_type())) //跟踪方式
                .setText(R.id.tv_trackcount, checkNull(preSaleRemarkBean.getVisit_times().toString())) //跟踪次数
                .setText(R.id.tv_trackbody, checkNull(preSaleRemarkBean.getRemarks())) //跟踪内容
                .setText(R.id.tv_nextvisttime, checkNull(DateUtil.formatDateTime(preSaleRemarkBean.getNext_date()))) //下次跟踪时间
                .addOnClickListener(R.id.rl_trackprogress);

        if (preSaleRemarkBean.getTrack_pro() > 3) {
            tv_trackNone.setVisibility(View.GONE);
            tv_trackExist.setVisibility(View.VISIBLE);
            rl_trackProgress.setClickable(true);
        } else {
            tv_trackNone.setVisibility(View.VISIBLE);
            tv_trackExist.setVisibility(View.GONE);
            rl_trackProgress.setClickable(false);
        }
        switch (preSaleRemarkBean.getTrack_pro()) {
            case Constant.TrackProgress.STATE_NONE:
                tv_trackNone.setText("无");
                break;
            case Constant.TrackProgress.STATE_INTENTION:
                tv_trackNone.setText("确认客户意向");
                break;
            case Constant.TrackProgress.STATE_DEMANDS:
                tv_trackNone.setText("客户明确表述需求");
                break;
            case Constant.TrackProgress.STATE_VISITSTORE:
                tv_trackNone.setText("已阅览资料或参观店面");
                break;
            case Constant.TrackProgress.STATE_SUPERIORITY:
                tv_trackExist.setText("明确知晓项目优势");
                break;
            case Constant.TrackProgress.STATE_CUSTOMERVISIT:
                tv_trackExist.setText("客户到访");
                break;
            case Constant.TrackProgress.STATE_SIGN:
                tv_trackExist.setText("已签约商铺");
                break;
            case Constant.TrackProgress.STATE_PAYMONEY:
                tv_trackExist.setText("签合同并打款到账");
                break;
        }
    }

    /**
     * 判断是否为空
     *
     * @param string
     * @return
     */
    public String checkNull(String string) {
        if (TextUtils.isEmpty(string)) {
            return "";
        }
        return string;
    }

}

